package com.harry.decoupling.impl.module;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.harry.basis.BaseGeneric;
import com.harry.basis.BasePoEntity;
import com.harry.decoupling.defi.module.RestfulApi;
import com.harry.decoupling.defi.proxy.RestfulMgrProxy;
import com.harry.utility.BeanCtxUtils;

public abstract class RestfulApiImpl<T extends BasePoEntity> extends BaseGeneric<T> implements RestfulApi<T> {

	@Override
	public void getone(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().getone(getEntityClass(), params, request, response, data);
	}

	@Override
	public void getlist(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().getlist(getEntityClass(), params, request, response, data);
	}

	@Override
	public void post(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().post(getEntityClass(), params, request, response, data);
	}

	@Override
	public void patch(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().patch(getEntityClass(), params, request, response, data);
	}

	@Override
	public void delete(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().delete(getEntityClass(), params, request, response, data);
	}

	@Override
	public void getexcel(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().getexcel(getEntityClass(), params, request, response, data);
	}

	@Override
	public void exists(Map<String, Object> params, HttpServletRequest request, HttpServletResponse response, Map<String, Object> data) throws Exception {
		mgr().exists(getEntityClass(), params, request, response, data);
	}

	private RestfulMgrProxy mgr() {
		return BeanCtxUtils.getBeanByType(RestfulMgrProxy.class);
	}
}
